/* ========================= */
/*    internal tips          */
var HooTip = new Class ({
	options: {
		blurClass: 'inputTip',
		text: 'please enter'
	},
	
	initialize: function(element, options) {
		this.element = element;
		this.element.focused = false;
		if ((!$defined(options) || !$defined(this.options.text)) && $defined(this.element.title)) this.options.text = this.element.title;		
		this.setOptions(this.options, options); 		
		if (!$defined(this.element.title)) this.element.title = this.options.text; 
		this.element.addEvents({
			blur: this.onBlur.bindWithEvent(this),
			focus: this.onFocus.bindWithEvent(this)
		});
		this.element.fireEvent('blur');
	},
	
	onBlur: function(nofocus) {
		if (this.element.value == '' && !(this.element.focused && nofocus == true)) {
			this.element.addClass(this.options.blurClass);
			this.element.value = this.options.text;
			this.element.focused = false;
		}
	},
	
	onFocus: function(nofocus) {
		if (this.element.value == this.options.text) {
			this.element.removeClass(this.options.blurClass);
			this.element.value = '';
			if (!$defined(nofocus) || !(nofocus==true)) {
				//this.element.value = '1';
				this.element.focused = true;
			}
		}		
	}
});

Element.implement({
    HooTip: function(options){
        return this._HooTip = new HooTip(this, options);
    }
});

HooTip.implement(new Events);
HooTip.implement(new Options);

//quick init: $$('input[type=text]', 'textarea').each(function(el) {el.inputTip();});